package cn.bobohost.user.service;

import cn.bobohost.user.mapper.UserMapper;
import cn.bobohost.user.pojo.User;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Map;

@Service
public class UserService {
    //注入mapper
    @Autowired
    private UserMapper userMapper;

    //分页查询
    public Page<User> findUserListPage(Map<String,Object> paramMap,int pageNum,int pageSize){
        //1.分页条件
        //2.业务条件
        QueryWrapper<User> qw=new QueryWrapper<>();
        //判断业务
        //名字
        if(!StringUtils.isEmpty(paramMap.get("name"))){
            qw.like("name",paramMap.get("name"));
        }

        //3.查询操作
        return  userMapper.selectPage(new Page<>(pageNum,pageSize)
                ,qw);
    }
}
